import { getEchart } from "@/service/echarts";
import type { IEcharts } from "@/type/echartsType";
import { defineStore } from "pinia";

const useEchartsStore = defineStore("echarts", {
  state: (): IEcharts => ({
    chargingPile: {},
    processMonitoring: {},
    dataAnalysis: {},
    chargingTop4: {},
    chargingStatistics: {},
    exceptionMonitoring: {},
  }),
  actions: {
    async fetchEchartAction() {
      const res = await getEchart();
      this.chargingPile = res.data.chargingPile;
      this.processMonitoring = res.data.processMonitoring;
      this.dataAnalysis = res.data.dataAnalysis;
      this.chargingTop4 = res.data.chargingTop4;
      this.chargingStatistics = res.data.chargingStatistics;
      this.exceptionMonitoring = res.data.exceptionMonitoring;
    },
  },
});

export default useEchartsStore;
